import WebIM from "easemob-websdk";
// import { Message } from "element-ui";
import config from "@/config";
// 引入Strophe方法
var Strophejs = require("strophe.js");
var Strophe = Strophejs.Strophe;

// 给Strophe.Connection 添加方法
Strophe.Connection.prototype.setJid = jid => {
  Strophe.Connection.jid = jid;
  Strophe.Connection.authzid = Strophe.getBareJidFromJid(
    Strophe.Connection.jid
  );
  Strophe.Connection.authcid = Strophe.getNodeFromJid(Strophe.Connection.jid);
};

Strophe.Connection.prototype.getJid = () => {
  return Strophe.Connection.jid;
};

window.Strophe = Strophe;
const conn = new WebIM.connection({
  https: config.webim.https,
  url: config.webim.xmppURL,
  apiUrl: config.webim.apiURL,
  isAutoLogin: config.webim.isAutoLogin,
  isMultiLoginSessions: config.webim.isMultiLoginSessions,
  heartBeatWait: config.webim.heartBeatWait,
  autoReconnectNumMax: config.webim.autoReconnectNumMax,
  autoReconnectInterval: config.webim.autoReconnectInterval
  // appKey: config.webim.appkey,
  // isHttpDNS: config.webim.isHttpDNS,
  // isStropheLog: config.webim.isStropheLog,
  // delivery: config.webim.delivery
});

export default {
  conn,
  WebIM: {
    ...WebIM,
    config
  }
};
